package jianzhiOfferII;
//剑指 Offer II 019. 最多删除一个字符得到回文
public class Num019_validPalindrome {
    public boolean validPalindrome(String s) {
        int l = 0 , r = s.length() - 1;
        while (l < r){
            if (s.charAt(l) != s.charAt(r)){
                return validPalindromeHelper(s , l + 1 , r) || validPalindromeHelper(s , l , r - 1);
            }else {
                l++;
                r--;
            }
        }
        return true;

    }
    public boolean validPalindromeHelper(String s , int l , int r){
        while (l < r){
            if (s.charAt(l) != s.charAt(r)){
                return false;
            }
            l++;
            r--;
        }
        return true;

    }
}
